package com.pk.platform.business.charge.service.impl;

import java.util.List;
import java.util.Map;

import com.pk.platform.business.charge.dao.ITuitionDetailDao;
import com.pk.platform.business.charge.service.ITuitionDetailService;
import com.pk.platform.business.charge.vo.TuitionDetailList;
import com.pk.platform.business.charge.vo.TuitionDetailVO;
import com.pk.platform.domain.charge.Tuition;
import com.pk.platform.domain.charge.TuitionDetail;
import com.pk.platform.util.DateConverter;
import com.pk.platform.util.constant.Constant;
import com.pk.platform.util.page.ListPage;
import com.pk.platform.util.page.Pager;

public class TuitionDetailServiceImpl implements ITuitionDetailService {

	private ITuitionDetailDao tuitionDetailDao;
	
	public void delTuitionDetail(String[] id, String tuitionId)
	{
		for(String oneId : id)
		{
			TuitionDetail td = this.queryTuitionDetailById(oneId);
			tuitionDetailDao.addOperateLog("删除指标费用明细", Constant.SUCCESSFUL, td.getTuition().getKindergarten());
			tuitionDetailDao.delete(TuitionDetail.class, oneId);
		}
		tuitionDetailDao.getHibernateSession().flush();
		
		Double total = tuitionDetailDao.queryTotalAmount(tuitionId);
		Tuition tuition = tuitionDetailDao.get(Tuition.class, tuitionId);
		tuition.setTotalAmount(total);
	}
	
	public Double queryTotalAmount(String tuitionId)
	{
		return tuitionDetailDao.queryTotalAmount(tuitionId);
	}
	
	public List<Map<String, Object>> queryYearOfOneTuition(String tuitionId)
	{
		return tuitionDetailDao.queryYearOfOneTuition(tuitionId);
	}
	

	public TuitionDetailList queryTuitionDetail(TuitionDetailVO tdvo, Pager pager) {
		return tuitionDetailDao.queryTuitionDetail(tdvo, pager);
	}
	
	public ListPage queryThisMonthPayList(String childId, Pager pager)
	{
		String today = DateConverter.getToday();
		String year = DateConverter.getYearStrByDate(today);
		String month = DateConverter.getMonthStrByDate(today);
		return tuitionDetailDao.queryThisMonthPayList(childId, year, month, pager);
	}
	
	public TuitionDetail queryTuitionDetailById(String id)
	{
		return tuitionDetailDao.get(TuitionDetail.class, id);
	}
	
	
	
	

	public ITuitionDetailDao getTuitionDetailDao() {
		return tuitionDetailDao;
	}

	public void setTuitionDetailDao(ITuitionDetailDao tuitionDetailDao) {
		this.tuitionDetailDao = tuitionDetailDao;
	}

}
